home *** CD-ROM | disk | FTP | other *** search
-
- <script language="JavaScript">
-
- MaxCartItems = 15;
-
- function getCookieVal (offset) {
- var endstr = document.cookie.indexOf (";", offset);
- if (endstr == -1)
- endstr = document.cookie.length;
- return unescape(document.cookie.substring(offset, endstr));
- }
-
- function GetCookie (name) {
- var arg = name + "=";
- var alen = arg.length;
- var clen = document.cookie.length;
- var i = 0;
- while (i < clen) {
- var j = i + alen;
- if (document.cookie.substring(i, j) == arg)
- return getCookieVal (j);
- i = document.cookie.indexOf(" ", i) + 1;
- if (i == 0) break;
- }
- return null;
- }
-
- function SetCookie (name, value) {
- var argv = SetCookie.arguments;
- var argc = SetCookie.arguments.length;
- var expires = (argc > 2) ? argv[2] : null;
- var path = (argc > 3) ? argv[3] : null;
- var domain = (argc > 4) ? argv[4] : null;
- var secure = (argc > 5) ? argv[5] : false;
- document.cookie = name + "=" + escape (value) +
- ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
- ((path == null) ? "" : ("; path=" + path)) +
- ((domain == null) ? "" : ("; domain=" + domain)) +
- ((secure == true) ? "; secure" : "");
- }
-
- function DeleteCookie (name) {
- var exp = new Date();
- exp.setTime (exp.getTime() - 1); // This cookie is history
- var cval = GetCookie (name);
- if (cval != null)
- document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
- }
-
- function ShowInvoice()
- {
- totprice = 0;
- itemlist = 0;
- TotQty = 0;
- TotWeight = 0;
- FinalTotWeight = 0;
-
-
- document.writeln('<table border=2 cellspacing=5 cellpadding=5>');
- document.writeln('<tr><td align=center><b>ID</b></td><td align=center><b>Description</b></td><td align=center><b>Qty</b></td><td align=center><b>Weight</b></td><td align=center><b>Price Each</b></td><td align=center><b>Price Total</b></td><td align=center><b>Comments</b></td></tr>');
-
- for(NumItems = 0; NumItems<MaxCartItems; NumItems++)
- {
- CookieName = "Cart" +NumItems;
- CookieValue = GetCookie(CookieName);
-
- if(CookieValue != null)
- {
- for(var i = 0;i <= CookieValue.length; i++)
- {
- // using 0192,0193,0194,0195,0196
- if (CookieValue.substring(i,i+1) == '[')
- {
- itemstart = i+1;
- }
- else if (CookieValue.substring(i,i+1) == '└')
- {
- ID = CookieValue.substring(itemstart, i);
- itemstart = i+1;
- }
- else if (CookieValue.substring(i,i+1) == '┴')
- {
- Sdesc = CookieValue.substring(itemstart, i);
- itemstart = i+1;
- }
- else if (CookieValue.substring(i,i+1) == '┬')
- {
- Price = CookieValue.substring(itemstart, i);
- itemstart = i+1;
- }
- else if (CookieValue.substring(i,i+1) == '├')
- {
- Qty = CookieValue.substring(itemstart, i);
- itemstart=i+1;
- }
- else if (CookieValue.substring(i,i+1) == '─')
- {
- Weight = CookieValue.substring(itemstart, i);
- itemstart = i+1;
- }
- else if (CookieValue.substring(i,i+1) == ']')
- {
- WeightUnit = CookieValue.substring(itemstart, i);
- itemstart = i+1;
-
- TotQty = TotQty + parseInt(Qty);
- TotWeight = Weight * Qty;
-
- ItemTotal = 0;
- ItemTotal = (eval(Price*Qty));
- temptotal = ItemTotal * 100;
- totprice = totprice + ItemTotal;
-
- FItemTotal = FloatFormat(ItemTotal,2);
- FTotWeight = FloatFormat(TotWeight,2);
-
- ConvertUnit(TotWeight,WeightUnit,'lbs');
- ConvertedWeight = NewUnitSize;
- FinalTotWeight = FinalTotWeight + NewUnitSize;
- FConvertedWeight = FloatFormat(ConvertedWeight,2);
- document.writeln('<input type=hidden name="Item" value="------------------------------------------------------------------------">');
- document.writeln('<input type=hidden name="ID" value="'+ID+'">');
- document.writeln('<input type=hidden name="Description" value="'+Sdesc+'">');
- document.writeln('<input type=hidden name="Qty" value="'+Qty+'">');
- document.writeln('<input type=hidden name="Price Each" value="'+Price+'">');
- document.writeln('<input type=hidden name="Total Price '+Qty+' items(s)" value="'+FItemTotal+'">');
- document.writeln('<tr><td>'+ID+'</td><td>'+Sdesc+'</td><td align=right>'+Qty+'</td><td align=right>'+FTotWeight+' '+WeightUnit+' = '+FConvertedWeight+' lbs</td><td align=right>'+Price+'</td><td align=right>'+FItemTotal+'</td><td><input type=text name="Comments" size=10></td></tr>');
- document.writeln('<input type=hidden name="Weight" value="'+FTotWeight+' '+WeightUnit+'">');
- document.writeln('<input type=hidden name="Weight Converted to lbs" value="'+FConvertedWeight+'">');
- }
- }
- }
- }
-
- Ftotprice = FloatFormat(totprice,2);
- document.writeln('<input type=hidden name="Totals" value="------------------------------------------------------------------------">');
- document.writeln('<tr><td colspan=5><b>Sub Total</b></td><td align=right>'+Ftotprice+'</td></tr>');
- document.writeln('<input type=hidden name="Sub Total" value="'+Ftotprice+'">');
-
- Tax = totprice * 7.250000;
- CTax = 0;
- FTax = FloatFormat(Tax,2);
- FCTax = FloatFormat(CTax,2);
- OCShipping = 0;
- Shipping = 0;
-
- if(FinalTotWeight >= 0.01 && FinalTotWeight >= 1)
- {
- Shipping = 3.50;
- TmpFinalTotWeight = FinalTotWeight - 1;
- TmpFinalTotWeight = TmpFinalTotWeight / 1;
- TmpFinalTotWeight = TmpFinalTotWeight * 0.35;
- Shipping = TmpFinalTotWeight + Shipping;
- }
-
- else if(FinalTotWeight >= 0.01 && FinalTotWeight <= 1)
- Shipping = 3.50;
-
- FShipping = FloatFormat(Shipping,2);
- FOCShipping = FloatFormat(OCShipping,2);
- FFinalTotWeight = FloatFormat(FinalTotWeight,2);
- document.writeln('<tr><td colspan=3><b>lbs</b></td><td align=right>'+FFinalTotWeight+' Total Weight</td></tr>');
- document.writeln('<input type=hidden name="lbs" value="'+FFinalTotWeight+' Total Weight">');
- document.writeln('<tr><td colspan=5><b>Shipping</b></td><td align=right>'+FShipping+'</td></tr>');
- document.writeln('<input type=hidden name="Shipping" value="'+FShipping+'">');
-
- NatFGrandTotal = FloatFormat(totprice + CTax + Shipping,2);
- ONatFGrandTotal = FloatFormat(totprice + Shipping + OCShipping,2);
- FGrandTotal = FloatFormat(totprice + Tax + CTax + Shipping,2);
- document.writeln('<tr><td colspan=5><b>Tx Sales Tax</b></td><td align=right>'+FTax+'</td></tr>');
- document.writeln('<input type=hidden name="Tx Sales Tax" value="'+FTax+'">');
- document.writeln('<tr><td colspan=5><b><font color=red>Total for Non-Tx residents in USA</font></b></td><td align=right><font color=red>$ '+NatFGrandTotal+'</font></td></tr>');
- document.writeln('<input type=hidden name="Total for Non-Tx residents in USA" value="$ '+NatFGrandTotal+'">');
- document.writeln('<tr><td colspan=5><b><font color=red>Total for Tx residents</font></b></td><td align=right><font color=red>$ '+FGrandTotal+'</font></td></tr>');
- document.writeln('<input type=hidden name="Total for Tx residents" value="$ '+FGrandTotal+'">');
- document.writeln('<tr><td colspan=5><b><font color=red>Total for sales outside of USA</font></b></td><td align=right><font color=red>$ '+ONatFGrandTotal+'</font></td></tr>');
- document.writeln('<input type=hidden name="Total for sales outside of USA" value="$ '+ONatFGrandTotal+'">');
- document.writeln('</table>');
- }
-
- function FloatFormat(expr,decplaces)
- {
- var str = "" + Math.round(eval(expr) * Math.pow(10,decplaces));
- while(str.length <= decplaces)
- {
- str = "0" + str;
- }
-
- var decpoint = str.length - decplaces;
- return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length);
- }
-
- rsize = 10; // rounding size
- oz_factor = 1; // ounces to ounces
- lbs_factor = 0.0625; // ounces to pounds
- mg_factor = 28349.5; // ounces to miligrams
- g_factor = 28.3495; // ounces to grams
- kg_factor = .0283495; // ounces to kilograms
- var UnitSize; // weight number being converted
- var OldUnit; // converting from
- var NewUnit; // converting to
- var NewUnitSize; // new weight in new unit
-
- function ConvertUnit(UnitSize,OldUnit,NewUnit)
- {
- // possible units
- // oz
- // lbs
- // mg
- // g
- // kg
-
- NewUnitSize = 0;
- TmpUnitSize = 0;
-
- // if not oz, convert to oz first
- if(OldUnit != 'oz')
- {
- if(OldUnit == 'lbs')
- {
- TmpUnitSize = UnitSize / lbs_factor;
- }
- else if(OldUnit == 'mg')
- {
- TmpUnitSize = UnitSize / mg_factor;
- }
- else if(OldUnit == 'g')
- {
- TmpUnitSize = UnitSize / g_factor;
- }
- else if(OldUnit == 'kg')
- {
- TmpUnitSize = UnitSize / kg_factor;
- }
- }
- else
- {
- // if oz, keep as is
- TmpUnitSize = UnitSize;
- }
-
- // since TmpUnitSize is now oz, convert to NewUnit;
- if(NewUnit == 'oz')
- {
- NewUnitSize = TmpUnitSize;
- }
- else if(NewUnit == 'lbs')
- {
- NewUnitSize = TmpUnitSize * lbs_factor;
- }
- else if(NewUnit == 'mg')
- {
- NewUnitSize = TmpUnitSize * mg_factor;
- }
- else if(NewUnit == 'g')
- {
- NewUnitSize = TmpUnitSize * g_factor;
- }
- else if(NewUnit == 'kg')
- {
- NewUnitSize = TmpUnitSize * kg_factor;
- }
- }
-
- </script>
-